<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>班级信息</title>
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/login.css">
	  <link rel="stylesheet" href="../../css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
</head>
<body>
<div class="layui-fluid">
		<div class="layui-row">
			<form class="layui-form" lay-filter="dataForm">
				<!-- 怎么一个div就相当于是一行数据  可以自己多复制一个就等于是添加了一行 -->
				<div class="layui-form-item">
					
					<!-- 一个lable 加它下面的div 就相当于是 一个  td -->
					<label for="advId" class="layui-form-label"> 
						<span class="x-red">*</span>编号
					</label>
					<div class="layui-input-inline">
						<input type="text" id="advId" name="advId" autocomplete="off"  readonly class="layui-input layui-disabled" >
					</div>
					
					<label for="advTitle" class="layui-form-label"> 
						<span class="x-red">*</span>广告标题
					</label>
					<div class="layui-input-inline">
						<input type="text" id="advTitle" name="advTitle"lay-verify="required" autocomplete="off" class="layui-input">
					</div>
					
				</div>
				
				<div class="layui-form-item">
					<label for="advContent" class="layui-form-label"> <span
						class="x-red">*</span>广告内容
					</label>
					<div class="layui-input-inline">
						<input type="text" id="advContent" name="advContent"lay-verify="required" autocomplete="off" class="layui-input">
					</div>
					
					<label for="advEndTime" class="layui-form-label"> <span
						class="x-red">*</span>到期时间
					</label>
					<div class="layui-input-inline">
						<input type="Date" id="advEndTime" name="advEndTime"lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				
				<div class="layui-form-item">
					<label for="L_repass" class="layui-form-label"></label>
					<button class="layui-btn" lay-filter="update" lay-submit="">修改</button>
				</div>
				
			</form>
		</div>
	</div>
</body>
<script>
	 //获取上个页面传递过来的 数据
	var rowsData = window.parent.formData;
	layui.use([ 'form', 'layer','layedit', 'laydate' ], function() {
		$ = layui.jquery;
		var form = layui.form, layer = layui.layer;
		
		//监听提交
		 form.on('submit(update)', function(data) {
			console.log(data);
			 $.ajax({
	            //请求方式
	            type : "POST",
	            //请求的媒体类型
	            //contentType: "application/json;charset=UTF-8",
	            //请求地址
	            url : "/../advertisement/updateAdvertisement",
	            //数据，(json字符串 JSON.stringify(data)),
	            data : data.field,
	            //请求成功
	            success : function(result) {
	            	if(result>0){
	            		//发异步，把数据提交给php
						layer.alert("修改成功", {
							icon : 6
						}, function() {
							// 获得frame索引
							var index = parent.layer.getFrameIndex(window.name);
							//关闭当前frame
							parent.layer.close(index);
							parent.location.reload();//刷新父页面更新修改后的表格数据
						});
	            	}else{
	            		//发异步，把数据提交给php
						layer.alert("修改失败！", {
							icon : 6
						});
	            	}
	            }
	        });
			return false;
		});  
		
		
		//填充表达数据 dataForm 就是你form表达框的  lay-filter属性  lay-filter="dataForm"
		form.val('dataForm', {
		      "advId": rowsData.advId // "name": "value"
		      ,"advTitle": rowsData.advTitle
		      ,"advContent": rowsData.advContent
		      ,"advEndTime": rowsData.advEndTime
		});
		
	});
        </script>

</html>